package pl.enigmatic.parser.string.java.awt;

import java.awt.Dimension;

import pl.enigmatic.parser.string.ArrayConverter;
import pl.enigmatic.parser.string.Converter;


public class DimensionConverter extends Converter<Dimension> {

	private final ArrayConverter<Integer> array = new ArrayConverter<Integer>(Integer[].class);

	@Override
	public Dimension convert(final String value) {
		final Integer[] size = array.convert(value);
		return new Dimension(size[0], size[1]);
	}

	@Override
	public String convertBack(final Dimension value) {
		return array.convertBack(new Integer[] { value.width, value.height });
	}

}
